package club.easin.utils;

import club.easin.enums.Exenum;

public class ReturnUtils {

    /**
     * 返回成功无对象
     * @param <T>
     * @return
     */
    public static <T> ReturnDto<T> returnsuccess(){
        return returnData(Exenum.SUCCESS.getCode(), Exenum.SUCCESS.getMessage(),null);
    }

    public static <T> ReturnDto<T> returnsuccess(T obj){
        return returnData(Exenum.SUCCESS.getCode(), Exenum.SUCCESS.getMessage(),obj);
    }

    public static <T> ReturnDto<T> returnError(String message){
        return returnData(Exenum.LOGIN_ERROR.getCode(),message,null);
    }
    public static <T> ReturnDto<T> returnError(Exenum exenum){
        return returnData(exenum.getCode(),exenum.getMessage(),null);
    }
    public static <T> ReturnDto<T> returnData(String code, String message, T obj){
        ReturnDto<T> returnDto=new ReturnDto<>();
        returnDto.setCode(code);
        returnDto.setMassage(message);
        returnDto.setData(obj);
        return returnDto;
    }
}
